/**
* Definition for singly-linked list.
* function ListNode(val) {
*     this.val = val;
*     this.next = null;
* }
*/
/**
* @param {ListNode} head
* @return {ListNode}
*/
export function reverseList(head) {
    if(head === null) {
        return head
    }   
    let [left, right] = [null, head]
    while(right !== null) {
        const temp = right.next
        right.next = left
        left = right
        right = temp
    }

    return left;
};